<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>代理充值明细</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
    <style>
        .layui-table-body .layui-table-cell {
            height: 50px; line-height: 50px;
        }
        .layui-laypage .layui-laypage-curr .layui-laypage-em{ background-color: #1E9FFF; }
        .layui-form-checked[lay-skin=primary] i{border-color: #1E9FFF!important;background-color: #1E9FFF;color:#fff;}
        .layui-form-checkbox[lay-skin=primary]:hover i{border-color:#1E9FFF;color:#fff}
        p.money {
            color: #f8a20f;
            font-size: 30px;
            font-weight: bold;
            height: 35px;
            line-height: 35px;
            padding: 5px 0;
            padding-bottom: 15px;
        }
    </style>
</head>
<body>

<div class="layui-fluid">

    <div class="layui-row">

        <div class="layui-col-md12">
            <div class="layui-card">

                <div lay-filter="listSearch" class="layui-form layui-card-header layuiadmin-card-header-auto" style="height:auto;padding:10px 15px;">

                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <select name="agent_id" lay-search>
                                <option value="0">请选择代理</option>
                                {volist name="agents" id="v"}
                                <option value="{$v.id}">{$v.account}</option>
                                {/volist}
                            </select>
                        </div>

                        <div class="layui-inline">
                            <button class="layui-btn layui-btn-normal layuiadmin-btn-admin" lay-submit lay-filter="LAY-list-front-search">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </button>
                            <button type="button" class="layui-btn layui-btn-primary" lay-submit lay-filter="LAY-reset">重置</button>
                        </div>

                    </div>

                </div>

                <div class="layui-card-body">


                    <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>

                </div>

            </div>
        </div>

    </div>

</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>

    layui.use('laydate', function () {
        var $ = layui.$;
        var laydate = layui.laydate;

        var nowTime = new Date().valueOf();
        var start = laydate.render({
            elem: '#dayStart',
            type: 'date',
            max: nowTime,
            done: function (value, date) {
                endMax = end.config.max;
                end.config.min = date;
                end.config.min.month = date.month - 1;
            }
        });
        var end = laydate.render({
            elem: '#dayEnd',
            type: 'date',
            max: nowTime,
            done: function (value, date) {
                if ($.trim(value) == '') {
                    var curDate = new Date();
                    date = {
                        'date': curDate.getDate(),
                        'month': curDate.getMonth() + 1,
                        'year': curDate.getFullYear()
                    };
                }
                start.config.max = date;
                start.config.max.month = date.month - 1;
            }
        });
    });

    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table','admin'], function(){

        var $ = layui.$
            ,form = layui.form
            ,table = layui.table;

        //监听搜索

        form.on('submit(LAY-list-front-search)', function(data){
            var field = data.field;
            //执行重载
            table.reload('LAY-list-manage', {
                where: field
                ,page: {
                    curr: 1  // 将页码重置为第一页
                }
            });
        });

        form.on('submit(LAY-reset)', function(data){

            form.val("listSearch", {
                "agent_id": "0"
            });
            form.render();
            table.reload('LAY-list-manage', {
                where: {"agent_id": "0"}
                ,page: {
                    curr: 1  // 将页码重置为第一页
                }
            });
        });

        //书籍管理
        table.render({
            elem: '#LAY-list-manage'
            ,url: "{:url('Agent/recharge_list_data')}" //模拟接口
            ,autoSort: false
            ,cols: [[
                {field: 'id', width: 100, title: '代理ID', sort: true, align:'center'}
                ,{field: 'agent_name', title: '代理商', align:'center'}
                ,{field: '{$date_rang[0]}', title: '{$date_rang[0]}', align:'center'}
                ,{field: '{$date_rang[1]}', title: '{$date_rang[1]}', align:'center'}
                ,{field: '{$date_rang[2]}', title: '{$date_rang[2]}', align:'center'}
                ,{field: '{$date_rang[3]}', title: '{$date_rang[3]}', align:'center'}
                ,{field: '{$date_rang[4]}', title: '{$date_rang[4]}', align:'center'}
                ,{field: '{$date_rang[5]}', title: '{$date_rang[5]}', align:'center'}
                ,{field: '{$date_rang[6]}', title: '{$date_rang[6]}', align:'center'}
            ]]
            ,page: true
            ,limit: 30
            ,height: 'full-220'
            ,text: '对不起，加载出现异常！'
        });

        //触发排序事件
        table.on('sort(LAY-list-manage)', function(obj){

            table.reload('LAY-list-manage', {
                initSort: obj //记录初始排序，如果不设的话，将无法标记表头的排序状态。
                ,where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                    field: obj.field //排序字段
                    ,order: obj.type //排序方式
                }
            });

        });

    });
</script>
</body>
</html>